package od;

import java.util.Scanner;

/**
 * Copyright (C) 2023 思创数码科技股份有限公司
 * <p/>
 * 版权所有
 * <p/>
 * 类名　　  : Test_1
 * 功能概要  :
 *
 * @author yangwk
 * @date 2025/3/4 19:58
 */
public class 最有效分配 {
    static long MIN_VALUE=Integer.MAX_VALUE;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int count = in.nextInt();
        int[][] arr = new int[count][3];
        int index=0;
        while (count-->0) { // 注意 whinile 处理多个 case
            arr[index][0]=in.nextInt();
            arr[index][1]=in.nextInt();
            arr[index][2]=in.nextInt();
            index++;
        }
        int sum = 0;
        int preIndex=-1;
        for (int i = 0; i < arr.length; i++) {
            int min=Integer.MAX_VALUE;
            int pos=Integer.MAX_VALUE;
            for (int j = 0; j < 3; j++) {
                if(j==preIndex){
                    continue;
                }
                if(arr[i][j]<=min){
                    min = arr[i][j];
                    pos=j;
                }
            }
            sum+=min;
            preIndex=pos;
        }
        System.out.println(sum);

    }
    public static void dfs(int depth,int[][] arr,int preIndex,int sum) {
        if(depth==arr.length){
            MIN_VALUE = Math.min(sum, MIN_VALUE);
            return;
        }
        int[] curArr = arr[depth];
        for (int i = 0; i < 3; i++) {
            if (i == preIndex) {
                continue;
            }
            int val = curArr[i];
            dfs(depth + 1, arr, i, sum + val);
        }
    }
    public static void  dfsCopy(int depth,int[][] arr,int preIndex,int sum) {
        if(sum>MIN_VALUE){
            return ;
        }
        if(depth==arr.length){
            MIN_VALUE = Math.min(sum, MIN_VALUE);
            return;
        }
        int[] curArr = arr[depth];
        for (int i = 0; i < 3; i++) {
            if (i == preIndex) {
                continue;
            }
            int val = curArr[i];
            dfs(depth + 1, arr, i, sum + val);
        }
    }
}
